<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper"> <a-form layout="inline" @keyup.enter.native="searchQuery"> <a-row
          :gutter="24"> <a-col :xl="6" :lg="7" :md="8" :sm="24"> <a-form-item label="苗棚名称"> <a-input placeholder="请输入苗棚名称"
                v-model="queryParam.deviceCode"></a-input> </a-form-item> </a-col> <a-col :xl="6" :lg="7" :md="8"
            :sm="24"> <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons"> <a-button
                type="primary" @click="searchQuery" icon="search">查询</a-button> <a-button type="primary"
                @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button> </span>
          </a-col> </a-row> </a-form> </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->


    <!-- table区域-begin -->
    <div>


      <a-table ref="table" size="middle" :scroll="{ x: true }" bordered rowKey="id" :columns="columns"
        :dataSource="dataSource" :pagination="ipagination" :loading="loading" class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt=""
            style="max-width:80px;font-size: 12px;font-style: italic;" />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a-button type="primary" icon="plus" @click="handlerOpenControl(record)">查看监控</a-button>
          <a-divider type="vertical" />

        </span>

      </a-table>
    </div>

    <!-- <zwgl-image-management-modal ref="modalForm" @ok="modalFormOk"></zwgl-image-management-modal> -->
    <zwgl-vedio-modal ref="vedioModal"></zwgl-vedio-modal>
  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ZwglVedioModal from './ZwglVedioModal.vue'
export default {
  name: 'ZwglImageManagementList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    ZwglVedioModal
  },
  data() {
    return {
      description: '影像管理管理页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: "center",
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '设备名称',
          align: "center",
          dataIndex: 'deviceName'
        },
        {
          title: '设备id',
          align: "center",
          dataIndex: 'deviceId'
        },
        {
          title: '设备编号',
          align: "center",
          dataIndex: 'deviceCode'
        },

        {
          title: '设备类型',
          align: "center",
          dataIndex: 'deviceTypeId'
        },
        {
          title: '设备类型名称',
          align: "center",
          dataIndex: 'deviceTypeName'
        },
        {
          title: '站点id',
          align: "center",
          dataIndex: 'stationId'
        },
        {
          title: '站点名称',
          align: "center",
          dataIndex: 'stationName'
        },
        {
          title: '视频地址',
          align: "center",
          dataIndex: 'hlsUrl',

        },
        {
          title: '在线状态',
          align: "center",
          dataIndex: 'online'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          fixed: "right",
          width: 147,
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: "/mpwlwjc/zwglImageManagement/list",
        delete: "/mpwlwjc/zwglImageManagement/delete",
        deleteBatch: "/mpwlwjc/zwglImageManagement/deleteBatch",
        exportXlsUrl: "/mpwlwjc/zwglImageManagement/exportXls",
        importExcelUrl: "mpwlwjc/zwglImageManagement/importExcel",

      },
      dictOptions: {},
      superFieldList: [],
    }
  },
  created() {
    this.getSuperFieldList();
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
  },
  methods: {
    initDictConfig() {
    },
    /**
     * 拍照
     * @param record
     */
    handlerImageControl(record) {
      this.$message.success("拍照成功")
    },
    /**
     * 查看监控
     * @param record
     */
    handlerOpenControl(record) {
      this.$refs.vedioModal.showDialog(record.hlsUrl)
    },
    getSuperFieldList() {
      let fieldList = [];
      fieldList.push({ type: 'string', value: 'deviceId', text: '设备id', dictCode: '' })
      fieldList.push({ type: 'string', value: 'deviceCode', text: '设备编号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'deviceName', text: '设备名称', dictCode: '' })
      fieldList.push({ type: 'string', value: 'deviceTypeId', text: '设备类型', dictCode: '' })
      fieldList.push({ type: 'string', value: 'deviceTypeName', text: '设备类型名称', dictCode: '' })
      fieldList.push({ type: 'string', value: 'stationId', text: '站点id', dictCode: '' })
      fieldList.push({ type: 'string', value: 'stationName', text: '站点名称', dictCode: '' })
      fieldList.push({ type: 'string', value: 'hlsUrl', text: '视频地址', dictCode: '' })
      fieldList.push({ type: 'string', value: 'online', text: '在线状态', dictCode: '' })
      this.superFieldList = fieldList
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>